import random
fr = open("test.txt",'r+')
dic = eval(fr.read())
print("是否开始背单词(Y/N)")
a=input().upper()
if a=='Y':
    total=0
    r=0
    w=0
    num=1
    while 1:
        print(f"第{num}个单词为:",end="")
        question=random.choice(list(dic))
        while 1:
            print(question)
            ans=input().lower()
            if ans==dic[question]:
                print("Right answer")
                r+=1
                break;
            else:
                w+=1
                print("Wrong answer,try again?(Y/N):")
                p=input().upper()
                if p == 'N':
                    break;
                else:
                    continue;
        num+=1
        a=input("是否停止背单词(Y/N):")
        if a=='Y':
            break
l=r/(r+w)
print(f"此次背单词成功率为{l*100}%")

#吴桢涛